package top.forforever.srb.core.controller.api;


import org.checkerframework.checker.fenum.qual.FenumTop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.forforever.srb.common.exception.Assert;
import top.forforever.srb.common.result.R;
import top.forforever.srb.common.result.ResponseEnum;
import top.forforever.srb.common.util.JwtUtils;
import top.forforever.srb.core.pojo.entity.BorrowInfo;
import top.forforever.srb.core.pojo.vo.BorrowInfoVO;
import top.forforever.srb.core.service.BorrowInfoService;
import top.forforever.srb.core.util.AuthContextHolder;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author Mr.Jiang
 * @since 2023-04-29
 */
@RestController
@RequestMapping("/api/core/borrowInfo")
public class ApiBorrowInfoController {

    @Autowired
    private BorrowInfoService borrowInfoService;

    @GetMapping("getBorrowInfoStatus")
    public R getBorrowInfoStatus(HttpServletRequest request) {
        Long userId = AuthContextHolder.getUserIdAndAuth(request);
        Integer borrowInfoStatus = borrowInfoService.getBorrowInfoStatus(userId);
        return R.ok().data("borrowInfoStatus",borrowInfoStatus);
    }

    @PostMapping("saveBorrowInfo")
    public R saveBorrowInfo(@RequestBody BorrowInfo borrowInfo, HttpServletRequest request) {
        Long userId = AuthContextHolder.getUserIdAndAuth(request);
        borrowInfoService.saveBorrowInfo(borrowInfo,userId);
        return R.ok();
    }




}

